package top.swimmer.tokenizer;

import java.io.Closeable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.time.LocalDateTime;

public class Too implements Serializable, Closeable {
    private transient Foo foo;
    private String c;

    public Too() {
        c = "Good man!";
        foo = new Foo();
    }

    @Override
    public void close() throws IOException {
        System.out.println("too close");
    }

    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        out.writeObject(foo.getA());
        out.writeObject(foo.getTime());
    }

    private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException {
        input.defaultReadObject();
        Foo foo = new Foo();
        foo.setA((String) input.readObject());
        foo.setTime((LocalDateTime) input.readObject());
        this.foo = foo;
    }
}
